TForm.Create

Otázka od: mstevlik@gamo.sk

2. 4. 2004 13:13

Hi all,
Chcem sa opytat, ako mam urobit constructor Create v mojom potomkovi
TFormu, tak ze tam chcem doplnit dalsi parameter
Priklad:

TfrmAbstract = class(TForm)
public
  constructor Create(AOwner: TComponent); override;
end;

TfrmStatistika = class(TfrmAbstract)
public
  constructor Create(AOwner: TComponent; ibTyp: Boolean); ...........
end;

Cim mam nahradit tie bodky?
Skusal som tam dat reintroduce
Ale ked som potom zavolal lrFrm := TfrmStatistika.Create tak sa mi volal
constructor TfrmAbstract  
Ide mi o to ze chcem nacisto nahradit constructor aby bolo povinne zadat i
ten druhy parameter
Viete mi niekto poradit?

Stevlik Marian
ISYS programator

GAMO a.s.
Kyjevske nam. 6
974 04 Banska Bystrica
mail: mstevlik@gamo.sk
tel: +421 48 4137935, 4372111
ip-tel: 421 48 4372098
mobil: +412 905 462010
ICQ: 34893645

Odpovedá: Petr Brant

2. 4. 2004 13:34

Potomka TForm jsem nedelal, ale resim takovou situaci takto:

constructor TNewMsg.Create(MSgTableProps: TMSgTableProps);
begin
 inherited Create(nil); <--------- volani zdedeneho konstruktoru, misto nil
muzes dat Owner, pokud je to zapotrebi
 FMSgTableProps:= MSgTableProps;
end;


RNDr. Petr Brant [brant@dcomm.cz]
http://web.redbox.cz/petr.brant



 Chcem sa opytat, ako mam urobit constructor Create v mojom potomkovi

 TFormu, tak ze tam chcem doplnit dalsi parameter
 Priklad:

 TfrmAbstract = class(TForm)
 public
   constructor Create(AOwner: TComponent); override;
 end;

 TfrmStatistika = class(TfrmAbstract)
 public
   constructor Create(AOwner: TComponent; ibTyp: Boolean);
...........
 end;


Odpovedá: Petr Daricek

2. 4. 2004 14:16

Ahoj,
  co takhle?
                  Petr Daricek


TAbstractForm=class(TForm)
public
  constructor Create(AOwner: TComponent); override;
End;

TConcreteForm=class(TAbstractForm)
public
  constructor Create(AOwner:TComponent;Parametr:Integer);
End;

implementation

{ TAbstractForm }

constructor TAbstractForm.Create(AOwner: TComponent);
begin
  inherited;
end;

{ TConcreteForm }

constructor TConcreteForm.Create(AOwner: TComponent; Parametr: Integer);
begin
  inherited Create(AOwner);
end;

Odpovedá: mstevlik@gamo.sk

2. 4. 2004 14:36

> Ahoj,
> co takhle?
> Petr Daricek
>
>
> TAbstractForm=class(TForm)
> public
> constructor Create(AOwner: TComponent); override;
> End;
>
> TConcreteForm=class(TAbstractForm)
> public
> constructor Create(AOwner:TComponent;Parametr:Integer);
> End;
>
> implementation
>
> { TAbstractForm }
>
> constructor TAbstractForm.Create(AOwner: TComponent);
> begin
> inherited;
> end;
>
> { TConcreteForm }
>
> constructor TConcreteForm.Create(AOwner: TComponent; Parametr: Integer);
> begin
> inherited Create(AOwner);
> end;

A ostane mi ten constructor toho TConcreteFormu stale virtualny?
Budem moct v nejakom potomkovy TConcreteFormu napisat constructor
Create(AOwner:TComponent;Parametr:Integer); override; ?

Stevlik Marian
ISYS programator

GAMO a.s.
Kyjevske nam. 6
974 04 Banska Bystrica
mail: mstevlik@gamo.sk
tel: +421 48 4137935, 4372111
ip-tel: 421 48 4372098
mobil: +412 905 462010
ICQ: 34893645

Odpovedá: Radim Kunz

2. 4. 2004 14:55

mstevlik@gamo.sk napsal(a):

>>Ahoj,
>> co takhle?
>> Petr Daricek
>>
>>
>>TAbstractForm=class(TForm)
>>public
>> constructor Create(AOwner: TComponent); override;
>>End;
>>
>>TConcreteForm=class(TAbstractForm)
>>public
>> constructor Create(AOwner:TComponent;Parametr:Integer);
>>End;
>>
>>
>>
>>
...

>A ostane mi ten constructor toho TConcreteFormu stale virtualny?
>Budem moct v nejakom potomkovy TConcreteFormu napisat constructor
>Create(AOwner:TComponent;Parametr:Integer); override; ?
>
>Stevlik Marian
>ISYS programator
>
>
>
Samozrejme nezustane, musis ho virtualnim udelat

TConcreteForm=class(TAbstractForm)
 public
   constructor Create(AOwner:TComponent;Parametr:Integer); virtual;
 End;


Ale bude ti to k necemu?

Radim